package org.shijiagen.user.controller;

import lombok.RequiredArgsConstructor;
import org.shijiagen.param.CartListParam;
import org.shijiagen.param.PageParam;
import org.shijiagen.pojo.User;
import org.shijiagen.user.service.UserService;
import org.shijiagen.utils.R;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("user")
@RequiredArgsConstructor
public class UserAdminController {

    private final UserService userService;

    @PostMapping("admin/list")
    public R listPage(@RequestBody PageParam param){
        return userService.listPage(param);
    }


    @PostMapping("admin/remove")
    public R remove(@RequestBody CartListParam param){
        return userService.remove(param.getUserId());
    }

    @PostMapping("admin/update")
    public R update(@RequestBody User user){
        return userService.update(user);
    }

    @PostMapping("admin/save")
    public R save(@RequestBody User user){
        return userService.save(user);
    }
}
